package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties(MinioProperties.class)
@Configuration
public class MinioConfiguration {
    @Autowired
    private MinioProperties minioProperties;


    @Bean
    public MinioClient minioClient(){
        MinioClient build = MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                //登录方法,用到账号和密码
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
                .build();
        return build;
    }
}
